﻿using Iodll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media.Media3D;
using AccustomeAttributedll;
using AM.Core.IO;
using FinalTestMachine.Connect;
using FinalTestMachine.Funs;
using AixRegisterInfodll;
using System.Diagnostics;

namespace FinalTestMachine.Motion.IO
{
    /// <summary>
    /// 控制卡的IO 管理
    /// </summary>
    public class StaticIOHelper
    {
        static StaticIOHelper()
        {
        }

        //初始化
        public static void Initial()
        {
            StaticInitial.Motion.ScanExcuteActionHandler += IOScanHelper.Scan;

            StaticInitial.Motion.actionClearErrEventHandler += () =>
            {
                Thread.Sleep(200);
            };

            //注册三色灯
            RM_dll2.Light.LightSwitchBase light = StaticInitial.Motion.LightSwitch;
            light.Buzzer.SetActionOFF(Out_Buzzer.Out_OFF);
            light.Buzzer.SetActionON(Out_Buzzer.Out_ON);
            light.GreenLight.SetActionOFF(Out_GreenLight.Out_OFF);
            light.GreenLight.SetActionON(Out_GreenLight.Out_ON);
            light.YellowLight.SetActionOFF(Out_YellowLight.Out_OFF);
            light.YellowLight.SetActionON(Out_YellowLight.Out_ON);
            light.RedLight.SetActionOFF(Out_RedLight.Out_OFF);
            light.RedLight.SetActionON(Out_RedLight.Out_ON);
            light.SetBuzzerActionTime(() => OtherParamHelper.Cur.BuzzerActionTime.GetValue);

            //三工位气缸防呆
            Cylinder_SiteBowlLightUpDown.WorkPosOutput.SafeCheck_ON += () =>
            {
                if (Motion.Aixs.Aix_Turn.Cur.GetAixRunState())
                {
                    throw new Exception("旋转轴运动中，无法动作工位3碗光源升降气缸！");
                }
            };

            Out_AirMain.Out_OFF();

            StaticInitial.Motion.CurOrder.In_ClearErr += new IoCheck(StaticIOHelper.In_ResetBtn.In).RisingCheck;
            StaticInitial.Motion.CurOrder.In_Pause += new IoCheck(StaticIOHelper.In_PauseBtn.In).RisingCheck;
            StaticInitial.Motion.CurOrder.In_Start += new IoCheck(StaticIOHelper.In_ProgrammerStartBtn.In).RisingCheck;
            StaticInitial.Motion.CurOrder.In_Stop += new IoCheck(StaticIOHelper.In_StopBtn.In).RisingCheck;
            StaticInitial.Motion.CurOrder.In_Res += new IoCheck(StaticIOHelper.In_InitialBtn.In).RisingCheck;

            if (In_AirMainCheck.In())
            {
                Out_AirMain.Out_ON();
            }

            Out_Power1Channel1.Out_OFF();
            Out_Power1Channel2.Out_OFF();
            Out_Power2Channel1.Out_OFF();
            Out_Power2Channel2.Out_OFF();

            Out_Buzzer.Out_OFF();
            Out_YellowLight.Out_ON();
            Out_GreenLight.Out_OFF();
            Out_RedLight.Out_OFF();
            StaticIOHelper.Out_StartLight1.Out_OFF();
            StaticIOHelper.Out_StartLight2.Out_OFF();
            Cylinder_SiteBowlLightUpDown.OriginPos(out _);
        }

        public static void Close()
        {
            Out_RedLight.Out_OFF();
            Out_YellowLight.Out_OFF();
            Out_GreenLight.Out_OFF();
            Out_Buzzer.Out_OFF();
        }

        public static void BuzzarReminder()
        {
            Task.Run(() =>
            {
                StaticIOHelper.Out_Buzzer.Out_ON();
                Thread.Sleep(200);
                StaticIOHelper.Out_Buzzer.Out_OFF();
            });
        }

        public static void DualLightTwinkle()
        {
            Task.Run(() => {
                Stopwatch stopwatch = Stopwatch.StartNew();
                while (stopwatch.ElapsedMilliseconds <= OtherParamHelper.Cur.twinkleTotalTime.GetValue)
                {
                    StartLightOn();
                    Thread.Sleep(OtherParamHelper.Cur.twinkleInterval.GetValue);
                    StartLightOff();
                }
                stopwatch.Stop();
            });
        }

        public static void ResInitial()
        {
            string err = string.Empty;

            Out_AirMain.Out_ON();

            if (!In_AirMainCheck.In())
            {
                throw new Exception("气源无反馈，请检查气源气压");
            }

            RM_dll2.CheckActionHelper checkActionHelper = new RM_dll2.CheckActionHelper();

            //4个工位断电和产品指示灯关闭
            Out_Power1Channel1.Out_OFF();
            Out_Power1Channel2.Out_OFF();
            Out_Power2Channel1.Out_OFF();
            Out_Power2Channel2.Out_OFF();

            if (!Cylinder_SiteBowlLightUpDown.OriginPos(out err))
            {
                throw new Exception(err);
            }

            Thread.Sleep(3000);

            if (Funs.FunCommSelection.Cur.IsUseSafeDoor)
            {
                Out_LeftDoor.Out_ON();
                Out_RightDoor.Out_ON();
                Out_BackDoor.Out_ON();
            }

            StartLightOff();

            Fun_ProductLight_OFF();

            ResetCylinder();
        }

        public static void ResetCylinder()
        {
            Cylinder_SiteBowlLightUpDown.OriginPos();
            Cylinder_Site4LeftLightUpDown.OriginPos();
            Cylinder_Site4RightLightUpDown.OriginPos();
            Cylinder_Site5Lift.OriginPos();
        }
        #region 工位一
        public static void StartLightOn()
        {
            Out_StartLight1.Out_ON();
            Out_StartLight2.Out_ON();
        }

        public static void StartLightOff()
        {
            Out_StartLight1.Out_OFF();
            Out_StartLight2.Out_OFF();
        }
        #endregion

        #region 工位三 碗光源

        /// <summary>
        /// 移动到低照度位置
        /// </summary>
        /// <returns></returns>
        public static bool Fun_MoveLowLight(out string error)
        {
            //if (!Cylinder_SiteBowlLightUpDown.OriginPos(out error))
            //{
            //    return false;
            //}

          //  Aixs.Aix_Site3Transplant.Cur.LowLightPos.Mov();

            if (!Cylinder_SiteBowlLightUpDown.WorkPos(out error))
            {
                return false;
            }

            return true;
        }

        /// <summary>
        /// 移动到三色温位置
        /// </summary>
        /// <returns></returns>
        public static bool Fun_MoveColorTemp(out string error)
        {
            //if (!Cylinder_SiteBowlLightUpDown.OriginPos(out error))
            //{
            //    return false;
            //}

           // Aixs.Aix_Site3Transplant.Cur.ThreeColorPos.Mov();

            if (!Cylinder_SiteBowlLightUpDown.WorkPos(out error))
            {
                return false;
            }

            return true;
        }

        public static void Fun_Light3()
        {
           /* Out_ThreeColorSwitch_1.Out_ON();
            Out_ThreeColorSwitch_2.Out_ON();*/
        }

        public static void Fun_LightTurnOff()
        {
            /*Out_ThreeColorSwitch_1.Out_OFF();
            Out_ThreeColorSwitch_2.Out_OFF();*/
        }

        #endregion 工位三 碗光源

        #region 信号检测

        public static bool CheckIn_Start()
        {
            if (In_Start1.In() && In_Start2.In())
            {
                return true;
            }
            return false;
        }

        public static bool Fun_CheckSocketAIsOpen()
        {
            if (Funs.FunSocketSettings.Cur.IsUseSocketASensor == false)
            {
                return true;
            }
            return In_SocketAOpen.In();
        }

        public static bool Fun_CheckSocketBIsOpen()
        {
            if (Funs.FunSocketSettings.Cur.IsUseSocketBSensor == false)
            {
                return true;
            }
            return In_SocketBOpen.In();
        }

        public static bool Fun_CheckSocketCIsOpen()
        {
            if (Funs.FunSocketSettings.Cur.IsUseSocketCSensor == false)
            {
                return true;
            }
            return In_SocketCOpen.In();
        }

        public static bool Fun_CheckSocketDIsOpen()
        {
            if (Funs.FunSocketSettings.Cur.IsUseSocketDSensor == false)
            {
                return true;
            }
            return In_SocketDOpen.In();
        }

        public static bool Fun_CheckSocketEIsOpen()
        {
            if (Funs.FunSocketSettings.Cur.IsUseSocketESensor == false)
            {
                return true;
            }
            return In_SocketEOpen.In();
        }

        public static bool Fun_CheckSocketFIsOpen()
        {
            if (Funs.FunSocketSettings.Cur.IsUseSocketFSensor == false)
            {
                return true;
            }
            return In_SocketFOpen.In();
        }

        public static bool Fun_CheckSocketClosed()
        {
            return Fun_CheckSocketAIsOpen() && Fun_CheckSocketBIsOpen() && Fun_CheckSocketCIsOpen() && Fun_CheckSocketDIsOpen() && Fun_CheckSocketEIsOpen() && Fun_CheckSocketFIsOpen();
        }

        #endregion 信号检测

        #region OK/NG灯控制

        /// <summary>
        /// 产品灯all off
        /// </summary>
        public static void Fun_ProductLight_OFF()
        {
            Out_ProductLight_Red.Out_OFF();
            Out_ProductLight_Green.Out_OFF();
        }

        /// <summary>
        /// 产品灯亮绿灯
        /// </summary>
        public static void Fun_ProductLightGreen()
        {
            Fun_ProductLight_OFF();
            Out_ProductLight_Green.Out_ON();
        }

        /// <summary>
        /// 产品灯亮红灯
        /// </summary>
        public static void Fun_ProductLightRed()
        {
            Fun_ProductLight_OFF();
            Out_ProductLight_Red.Out_ON();

            Thread thread = new Thread(() =>
            {
                //产品NG时，蜂鸣器响1秒
                Out_Buzzer.Out_ON();
                Thread.Sleep(1000);
                Out_Buzzer.Out_OFF();
            });

            thread.IsBackground = true;
            thread.Start();
        }

        #endregion OK/NG灯控制

        #region 程控电源

        public static void PowerOn()
        {
            Out_Power1Channel1.Out_ON();
            Out_Power1Channel2.Out_ON();
            Out_Power2Channel1.Out_ON();
            Out_Power2Channel2.Out_ON();
            Out_Power3Channel1.Out_ON();
            Out_Power3Channel2.Out_ON();
        }

        public static void PowerOff()
        {
            Out_Power1Channel1.Out_OFF();
            Out_Power1Channel2.Out_OFF();
            Out_Power2Channel1.Out_OFF();
            Out_Power2Channel2.Out_OFF();
            Out_Power3Channel1.Out_OFF();
            Out_Power3Channel2.Out_OFF();
        }

        

        #endregion 程控电源

        #region 动态范围挡板

        /// <summary>
        /// 挡板挡住
        /// </summary>
        public static void BaffleWork()
        {
            //Out_baffleStart.Out_ON();
            //Out_baffleReversal.Out_ON();
        }

        /// <summary>
        /// 挡板回原
        /// </summary>
        public static void BaffleHome()
        {
            //Out_baffleStart.Out_ON();
            //Out_baffleReversal.Out_OFF();
        }

        /// <summary>
        /// 挡板Stop
        /// </summary>
        public static void BaffleStop()
        {
            //Out_baffleStart.Out_OFF();
            //Out_baffleReversal.Out_OFF();
        }

        #endregion 动态范围挡板



        #region Input [count=38] 	[名称,解释,IO模块名称,Index]
        #region 202A4
        /// <summary>
        /// 急停安全继电器反馈	IO=202A4,Index=8
        /// </summary>
        public static readonly IoInHelper In_EMG;

        /// <summary>
        /// 光栅安全继电器反馈	IO=202A4,Index=9
        /// </summary>
        public static readonly IoInHelper In_Safe_Checked;

        /// <summary>
        /// 左门锁信号锁定反馈	IO=202A4,Index=10
        /// </summary>
        public static readonly IoInHelper In_LeftDoorInsertChecked;

        /// <summary>
        /// 左门锁信号插销反馈	IO=202A4,Index=11
        /// </summary>
        public static readonly IoInHelper In_LeftDoorChecked;

        /// <summary>
        /// 右门锁信号锁定反馈	IO=202A4,Index=12
        /// </summary>
        public static readonly IoInHelper In_RightDoorInsertChecked;

        /// <summary>
        /// 右门锁信号插销反馈	IO=202A4,Index=13
        /// </summary>
        public static readonly IoInHelper In_RightDoorChecked;

        /// <summary>
        /// 后门锁信号锁定反馈	IO=202A4,Index=14
        /// </summary>
        public static readonly IoInHelper In_BackDoorInsertChecked;

        /// <summary>
        /// 后门锁信号插销反馈	IO=202A4,Index=15
        /// </summary>
        public static readonly IoInHelper In_BackDoorChecked;

        /// <summary>
        /// 启动按钮	IO=202A4,Index=16
        /// </summary>
        public static readonly IoInHelper In_ProgrammerStartBtn;

        /// <summary>
        /// 停止按钮	IO=202A4,Index=17
        /// </summary>
        public static readonly IoInHelper In_StopBtn;

        /// <summary>
        /// 复位按钮	IO=202A4,Index=18
        /// </summary>
        public static readonly IoInHelper In_ResetBtn;

        /// <summary>
        /// 暂停按钮	IO=202A4,Index=19
        /// </summary>
        public static readonly IoInHelper In_PauseBtn;

        /// <summary>
        /// 初始化按钮	IO=202A4,Index=20
        /// </summary>
        public static readonly IoInHelper In_InitialBtn;

        /// <summary>
        /// 双启动按钮1	IO=202A4,Index=21
        /// </summary>
        public static readonly IoInHelper In_Start1;

        /// <summary>
        /// 双启动按钮2	IO=202A4,Index=22
        /// </summary>
        public static readonly IoInHelper In_Start2;

        /// <summary>
        /// 总气反馈	IO=202A4,Index=23
        /// </summary>
        public static readonly IoInHelper In_AirMainCheck;

        /// <summary>
        /// 左门接近	IO=202A4,Index=24
        /// </summary>
        public static readonly IoInHelper In_LeftDoorNear;

        /// <summary>
        /// 后门接近	IO=202A4,Index=25
        /// </summary>
        public static readonly IoInHelper In_BackDoorNear;

        /// <summary>
        /// 右门接近	IO=202A4,Index=26
        /// </summary>
        public static readonly IoInHelper In_RightDoorNear;

        /// <summary>
        /// NG料盒感应	IO=202A4,Index=27
        /// </summary>
        public static readonly IoInHelper In_NgBoxChecked;

        /// <summary>
        /// 扫码枪感应	IO=202A4,Index=28
        /// </summary>
        public static readonly IoInHelper In_LoadScannerTriggerChecked;

        #endregion

        #region 202A5
        /// <summary>
        /// 图卡接近感应左1	IO=202A5,Index=6
        /// </summary>
        public static readonly IoInHelper In_ImageCardReachSensorLeft1;

        /// <summary>
        /// 图卡接近感应左2	IO=202A5,Index=7
        /// </summary>
        public static readonly IoInHelper In_ImageCardReachSensorLeft2;

        /// <summary>
        /// 图卡接近感应左3	IO=202A5,Index=8
        /// </summary>
        public static readonly IoInHelper In_ImageCardReachSensorLeft3;

        /// <summary>
        /// 图卡接近感应右1	IO=202A5,Index=9
        /// </summary>
        public static readonly IoInHelper In_ImageCardReachSensorRight1;

        /// <summary>
        /// 图卡接近感应右2	IO=202A5,Index=10
        /// </summary>
        public static readonly IoInHelper In_ImageCardReachSensorRight2;

        /// <summary>
        /// 图卡接近感应右3	IO=202A5,Index=11
        /// </summary>
        public static readonly IoInHelper In_ImageCardReachSensorRight3;

        #endregion

        #region 202A6
        /// <summary>
        /// 治具开合检测1	IO=202A6,Index=0
        /// </summary>
        public static readonly IoInHelper In_SocketAOpen;

        /// <summary>
        /// 治具开合检测2	IO=202A6,Index=1
        /// </summary>
        public static readonly IoInHelper In_SocketBOpen;

        /// <summary>
        /// 治具开合检测3	IO=202A6,Index=2
        /// </summary>
        public static readonly IoInHelper In_SocketCOpen;

        /// <summary>
        /// 治具开合检测4	IO=202A6,Index=3
        /// </summary>
        public static readonly IoInHelper In_SocketDOpen;

        /// <summary>
        /// 治具开合检测5	IO=202A6,Index=4
        /// </summary>
        public static readonly IoInHelper In_SocketEOpen;

        /// <summary>
        /// 治具开合检测6	IO=202A6,Index=5
        /// </summary>
        public static readonly IoInHelper In_SocketFOpen;

      

        #endregion
        #endregion



        #region Output [count=49] 	[名称,解释,组名称,IO模块名称,Index,是否显示按钮,按钮名称]
        #region 202A6
        /// <summary>
        /// 绿色指示灯	IO=202A6,Index=8,IsShowButton=False ButtonText=绿色指示灯
        /// </summary>
        [GroupRemark("三色灯")]
        public static readonly IoOutHepler Out_GreenLight;

        /// <summary>
        /// 红色指示灯	IO=202A6,Index=9,IsShowButton=False ButtonText=红色指示灯
        /// </summary>
        [GroupRemark("三色灯")]
        public static readonly IoOutHepler Out_RedLight;

        /// <summary>
        /// 黄色指示灯	IO=202A6,Index=10,IsShowButton=False ButtonText=黄色指示灯
        /// </summary>
        [GroupRemark("三色灯")]
        public static readonly IoOutHepler Out_YellowLight;

        /// <summary>
        /// 蜂鸣器	IO=202A6,Index=11,IsShowButton=False ButtonText=蜂鸣器
        /// </summary>
        [GroupRemark("三色灯")]
        public static readonly IoOutHepler Out_Buzzer;

        /// <summary>
        /// 扫码枪触发	IO=202A6,Index=12,IsShowButton=True ButtonText=扫码枪触发
        /// </summary>
        [GroupRemark("扫码枪")]
        public static readonly IoOutHepler Out_LoadScanTrigger;

        /// <summary>
        /// 内部扫码枪触发	IO=202A6,Index=13,IsShowButton=True ButtonText=内部扫码枪触发
        /// </summary>
        [GroupRemark("扫码枪")]
        public static readonly IoOutHepler Out_SocketScanTrigger;

        /// <summary>
        /// LED灯控制	IO=202A6,Index=14,IsShowButton=True ButtonText=LED灯控制
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_LED;

        /// <summary>
        /// 总气控制	IO=202A6,Index=15,IsShowButton=True ButtonText=总气控制
        /// </summary>
        [GroupRemark("其他")]
        public static readonly IoOutHepler Out_AirMain;

        /// <summary>
        /// 启动按钮灯	IO=202A6,Index=16,IsShowButton=True ButtonText=启动按钮灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_StartBtnLED;

        /// <summary>
        /// 停止按钮灯	IO=202A6,Index=17,IsShowButton=True ButtonText=停止按钮灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_StopBtnLED;

        /// <summary>
        /// 复位按钮灯	IO=202A6,Index=18,IsShowButton=True ButtonText=复位按钮灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_ResetBtnLED;

        /// <summary>
        /// 暂停按钮灯	IO=202A6,Index=19,IsShowButton=True ButtonText=暂停按钮灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_PauseBtnLED;

        /// <summary>
        /// 初始化按钮灯	IO=202A6,Index=20,IsShowButton=True ButtonText=初始化按钮灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_InitialBtnLED;

        /// <summary>
        /// 双启动灯1	IO=202A6,Index=21,IsShowButton=True ButtonText=单手触摸按钮灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_StartLight1;

        /// <summary>
        /// 双启动灯2	IO=202A6,Index=22,IsShowButton=True ButtonText=单手触摸按钮灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_StartLight2;

        /// <summary>
        /// OK灯	IO=202A6,Index=23,IsShowButton=True ButtonText=OK灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_ProductLight_Green;

        /// <summary>
        /// NG灯	IO=202A6,Index=24,IsShowButton=True ButtonText=NG灯
        /// </summary>
        [GroupRemark("灯控制")]
        public static readonly IoOutHepler Out_ProductLight_Red;

        /// <summary>
        /// 左门锁锁定	IO=202A6,Index=25,IsShowButton=True ButtonText=左门锁锁定
        /// </summary>
        [GroupRemark("门锁")]
        public static readonly IoOutHepler Out_LeftDoor;

        /// <summary>
        /// 右门锁锁定	IO=202A6,Index=26,IsShowButton=True ButtonText=右门锁锁定
        /// </summary>
        [GroupRemark("门锁")]
        public static readonly IoOutHepler Out_RightDoor;

        /// <summary>
        /// 后门锁锁定	IO=202A6,Index=27,IsShowButton=True ButtonText=后门锁锁定
        /// </summary>
        [GroupRemark("门锁")]
        public static readonly IoOutHepler Out_BackDoor;

        /// <summary>
        /// NG料盒解锁	IO=202A6,Index=28,IsShowButton=True ButtonText=NG料盒解锁
        /// </summary>
        [GroupRemark("其他")]
        public static readonly IoOutHepler Out_NGBoxUnLock;

        #endregion

        #region 202A7
        /// <summary>
        /// 采集卡1触发	IO=202A7,Index=3,IsShowButton=True ButtonText=采集卡1触发
        /// </summary>
        [GroupRemark("程控电源")]
        public static readonly IoOutHepler Out_Power1Channel1;

        /// <summary>
        /// 鬼影1	IO=202A7,Index=9,IsShowButton=True ButtonText=鬼影1
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost1;

        /// <summary>
        /// 鬼影2	IO=202A7,Index=10,IsShowButton=True ButtonText=鬼影2
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost2;

        /// <summary>
        /// 鬼影3	IO=202A7,Index=11,IsShowButton=True ButtonText=鬼影3
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost3;

        /// <summary>
        /// 鬼影4	IO=202A7,Index=12,IsShowButton=True ButtonText=鬼影4
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost4;

        /// <summary>
        /// 鬼影5	IO=202A7,Index=13,IsShowButton=True ButtonText=鬼影5
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost5;

        /// <summary>
        /// 鬼影6	IO=202A7,Index=14,IsShowButton=True ButtonText=鬼影6
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost6;

        /// <summary>
        /// 鬼影7	IO=202A7,Index=15,IsShowButton=True ButtonText=鬼影7
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost7;

        /// <summary>
        /// 鬼影8	IO=202A7,Index=16,IsShowButton=True ButtonText=鬼影8
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost8;

        /// <summary>
        /// 鬼影9	IO=202A7,Index=17,IsShowButton=True ButtonText=鬼影9
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost9;

        /// <summary>
        /// 鬼影10	IO=202A7,Index=18,IsShowButton=True ButtonText=鬼影10
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost10;

        /// <summary>
        /// 鬼影11	IO=202A7,Index=19,IsShowButton=True ButtonText=鬼影11
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost11;

        /// <summary>
        /// 鬼影12	IO=202A7,Index=20,IsShowButton=True ButtonText=鬼影12
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost12;

        /// <summary>
        /// 鬼影13	IO=202A7,Index=21,IsShowButton=True ButtonText=鬼影13
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost13;

        /// <summary>
        /// 鬼影14	IO=202A7,Index=22,IsShowButton=True ButtonText=鬼影14
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost14;

        /// <summary>
        /// 鬼影15	IO=202A7,Index=23,IsShowButton=True ButtonText=鬼影15
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost15;

        /// <summary>
        /// 鬼影16	IO=202A7,Index=24,IsShowButton=True ButtonText=鬼影16
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost16;

        /// <summary>
        /// 鬼影17	IO=202A7,Index=25,IsShowButton=True ButtonText=鬼影17
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost17;

        /// <summary>
        /// 鬼影18	IO=202A7,Index=26,IsShowButton=True ButtonText=鬼影18
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost18;

        /// <summary>
        /// 鬼影19	IO=202A7,Index=27,IsShowButton=True ButtonText=鬼影19
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost19;

        /// <summary>
        /// 鬼影20	IO=202A7,Index=28,IsShowButton=True ButtonText=鬼影20
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost20;

        /// <summary>
        /// 鬼影21	IO=202A7,Index=29,IsShowButton=True ButtonText=鬼影21
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost21;

        /// <summary>
        /// 鬼影22	IO=202A7,Index=30,IsShowButton=True ButtonText=鬼影22
        /// </summary>
        [GroupRemark("鬼影")]
        public static readonly IoOutHepler Out_Ghost22;

        /// <summary>
        /// 获取指定的鬼影字段对象
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public static IoOutHepler GetGhostX(int index)
        {
            string fieldName = $"Out_Ghost{index}";
            return GlobalParams.GetStaticFieldValue<IoOutHepler>(typeof(StaticIOHelper), fieldName);
        }

        /// <summary>
        /// 打开指定的鬼影
        /// </summary>
        /// <param name="index"></param>
        public static void OpenGhost(int index)
        {
            GetGhostX(index).Out_ON();
        }

        /// <summary>
        /// 关闭指定的鬼影
        /// </summary>
        /// <param name="index"></param>
        public static void CloseGhost(int index) { 
            GetGhostX(index).Out_OFF(); 
        }

        public static void OpenAllGhosts()
        {
            for(int i = 1; i <= 22; i++)
            {
                OpenGhost(i);
            }
        }

        public static void CloseAllGhost()
        {
            for (int i = 1; i <= 22; i++)
            {
                CloseGhost(i);
            }
        }

        #endregion

        #region 202A4
        /// <summary>
        /// 采集卡2触发	IO=202A4,Index=4,IsShowButton=True ButtonText=采集卡2触发
        /// </summary>
        [GroupRemark("程控电源")]
        public static readonly IoOutHepler Out_Power1Channel2;

        /// <summary>
        /// 采集卡3触发	IO=202A4,Index=5,IsShowButton=True ButtonText=采集卡3触发
        /// </summary>
        [GroupRemark("程控电源")]
        public static readonly IoOutHepler Out_Power2Channel1;

        /// <summary>
        /// 采集卡4触发	IO=202A4,Index=6,IsShowButton=True ButtonText=采集卡4触发
        /// </summary>
        [GroupRemark("程控电源")]
        public static readonly IoOutHepler Out_Power2Channel2;

        /// <summary>
        /// 采集卡4触发	IO=202A4,Index=7,IsShowButton=True ButtonText=采集卡4触发
        /// </summary>
        [GroupRemark("程控电源")]
        public static readonly IoOutHepler Out_Power3Channel1;

        /// <summary>
        /// 采集卡4触发	IO=202A4,Index=8,IsShowButton=True ButtonText=采集卡4触发
        /// </summary>
        [GroupRemark("程控电源")]
        public static readonly IoOutHepler Out_Power3Channel2;

        #endregion

        #endregion


      #region Cylinder [count=4] 	[Key,Name,工作位输出IO(多个点位用/分隔，比如:Out2.0/Out3.5,原点位输出IO,工作位输入IO,原点位输入IO,所属组,工作位输出是否取反,原点位输出是否取反,输入是否屏蔽]
        /// <summary>
        /// 工位三光碗升降气缸	 OutAct=202A6.29,OutOrg=202A6.30,InAct=202A5.0 InOrg=202A5.1
        /// </summary>
        [GroupRemark("气缸")]
        public static readonly Cylinder Cylinder_SiteBowlLightUpDown;

        /// <summary>
        /// 工位四左光源升降气缸	 OutAct=202A4.29,OutOrg=202A4.28,InAct=202A2.28 InOrg=202A2.26
        /// </summary>
        [GroupRemark("气缸")]
        public static readonly Cylinder Cylinder_Site4LeftLightUpDown;

        /// <summary>
        /// 工位四右光源升降气缸	 OutAct=202A4.30,OutOrg=202A4.29,InAct=202A2.29 InOrg=202A2.27
        /// </summary>
        [GroupRemark("气缸")]
        public static readonly Cylinder Cylinder_Site4RightLightUpDown;

        /// <summary>
        /// 工位五升降气缸	 OutAct=202A7.1,OutOrg=202A7.2,InAct=202A5.4 InOrg=202A5.5
        /// </summary>
        [GroupRemark("气缸")]
        public static readonly Cylinder Cylinder_Site5Lift;

        #endregion


    }
}